package com.secsbrain.development.biz.job;

import java.util.List;

import com.secsbrain.development.biz.IDeployPlanTestService;
import com.secsbrain.development.biz.constant.EnumDefinition;
import com.secsbrain.development.dal.model.DeployPlanTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 自动化测试定时任务
 *
 * @author zhaoyi
 */
@Component
public class AutoTestJob {
	
    private static final Logger logger = LoggerFactory.getLogger(AutoTestJob.class);
	
	@Autowired
    IDeployPlanTestService deployPlanTestService;

	// 每3分钟执行
	@Scheduled(cron = "0 0/3 * * * ?")
	public void runAutoTest() {
		logger.debug("检查是否需要执行自动化测试任务开始...");
		
		DeployPlanTest deployPlanTestParam=new DeployPlanTest();
		deployPlanTestParam.setStatus(EnumDefinition.TestStatus.INIT.getCode());
		List<DeployPlanTest> list=deployPlanTestService.selectList(deployPlanTestParam);
		for(DeployPlanTest deployPlanTest:list){
			deployPlanTestService.handleAutoTest(deployPlanTest);
		}
	}

}
